package com.luobo.yfh;

import com.alibaba.fastjson.JSON;
import com.luobo.yfh.vo.*;
import com.luobo.yfh.vo.request.*;
import com.luobo.yfh.vo.respone.AccountCheckingVO;
import com.luobo.yfh.vo.respone.OrderApplyVo;
import com.luobo.yfh.vo.respone.PayApplyVo;
import com.luobo.yfh.vo.respone.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("continent")
@Api(tags = "金融机构需提供接口")
public class DaDiController {




    @GetMapping("test")
    public Result test(){
    //    throw new  RuntimeException();
        return Result.success();
    }




    @PostMapping("orderApply")
    @ApiOperation(value = "保单申请<OK>", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<OrderApplyVo> orderApply(@RequestBody @Valid RequestVo<GuaranteeOrder> requestVo, BindingResult bindingResult)  {

        Result<OrderApplyVo> result = new Result<OrderApplyVo>();
        OrderApplyVo orderApplyVo = new OrderApplyVo();
        result.setData(orderApplyVo);
        return result;
    }

    @PostMapping("getPayLink")
    @ApiOperation(value = "获取支付链接<OK>", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<PayApplyVo> getPayLink(@RequestBody @Valid RequestVo<GetVo> requestVo, BindingResult bindingResult) {

        Result<PayApplyVo> result = new Result<PayApplyVo>();
        PayApplyVo payApplyVo = new PayApplyVo();
        result.setData(payApplyVo);
        return result;
    }

    @PostMapping("orderInquire")
    @ApiOperation(value = "订单查询", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<PayApplyVo> orderInquiry(@RequestBody @Valid RequestVo<GetVo> requestVo, BindingResult bindingResult) {
        Result<PayApplyVo> result = new Result<PayApplyVo>();
        PayApplyVo payApplyVo = new PayApplyVo();
        result.setData(payApplyVo);
        return result;
    }

    @PostMapping("invoiceApply")
    @ApiOperation(value = "发票申请", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result invoiceApply(@RequestBody @Valid RequestVo<GetVo> requestVo, BindingResult bindingResult) {
        if(bindingResult.hasErrors()){
            return Result.error();
        }
        return Result.success();
    }

    @PostMapping("invoiceInquire")
    @ApiOperation(value = "发票查询", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result invoiceInquiry(@RequestBody @Valid RequestVo requestVo, BindingResult bindingResult) {
        if(bindingResult.hasErrors()){
            return Result.error();
        }
        return Result.success();
    }

    @PostMapping("chargebackApply")
    @ApiOperation(value = "退保申请", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result chargebackApply(@RequestBody @Valid RequestVo<GetVo> requestVo, BindingResult bindingResult) {
        if(bindingResult.hasErrors()){
            return Result.error();
        }
        return Result.success();
    }

    @PostMapping("chargebackInquire")
    @ApiOperation(value = "退保查询", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result chargebackInquire(@RequestBody @Valid RequestVo requestVo, BindingResult bindingResult) {
        if(bindingResult.hasErrors()){
            return Result.error();
        }
        return Result.success();
    }

    @PostMapping("guaranteeCheck")
    @ApiOperation(value = "保单查验", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result a(@RequestBody @Valid RequestVo requestVo, BindingResult bindingResult) {
        if(bindingResult.hasErrors()){
            return Result.error();
        }
        return Result.success();
    }

    @PostMapping("accountChecking")
    @ApiOperation(value = "对账", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<AccountCheckingVO> accountChecking(@RequestBody @Valid RequestVo requestVo, BindingResult bindingResult) {
        if(bindingResult.hasErrors()){
            return Result.error();
        }
        return Result.success();
    }


    public static void main(String[] args) {
        RequestVo.Head head = new RequestVo.Head("apply","DaDi",1584754824L);

        Map map = new HashMap();
        map.put("cmd","apply");
        map.put("timestamp",1584754824L);
        map.put("fcid","DaDi");

        System.out.println(MD5Util.createSign(map));
        System.out.println(MD5Util.createSign(head));

        System.out.println(String.valueOf(false));
        System.out.println(JSON.toJSONString(false));


        String encry = AesUtil.encry(Result.success());

        String desEncry = AesUtil.desEncry(encry);

        System.out.println(encry);
        System.out.println(desEncry);


    }
}
